package net.bezrabotnih.cabinet.client.activity;

import net.bezrabotnih.cabinet.client.place.CreateJobPlace;
import net.bezrabotnih.cabinet.client.place.EditJobPlace;
import net.bezrabotnih.cabinet.client.place.FindJobPlace;
import net.bezrabotnih.cabinet.client.place.MenuItemPlace;
import net.bezrabotnih.cabinet.client.place.PerformerJobsPlace;
import net.bezrabotnih.cabinet.client.place.PerformerMainMenuItemPlace;
import net.bezrabotnih.cabinet.client.place.PerformerMainPlace;
import net.bezrabotnih.cabinet.client.place.ProfileEditPlace;
import net.bezrabotnih.cabinet.client.place.ProfilePlace;
import net.bezrabotnih.cabinet.client.place.ProviderJobsPlace;
import net.bezrabotnih.cabinet.client.place.ProviderMainMenuItemPlace;
import net.bezrabotnih.cabinet.client.place.ProviderMainPlace;
import net.bezrabotnih.cabinet.client.request.CabinetRequestFactory;

import com.google.gwt.activity.shared.Activity;
import com.google.gwt.activity.shared.ActivityMapper;
import com.google.gwt.place.shared.Place;
import com.google.gwt.place.shared.PlaceController;
import com.google.inject.Inject;

public class MasterActivityMapper implements ActivityMapper {
	
	private CabinetRequestFactory requests;
	private PlaceController placeController;

	
	@Inject
	public MasterActivityMapper(CabinetRequestFactory requests,PlaceController placeController) {
		this.requests = requests;
        this.placeController = placeController;
	}

	@Override
	public Activity getActivity(Place place) {
		if (place instanceof ProfilePlace) return new ProfileActivity((ProfilePlace)place,requests,placeController);
		if (place instanceof ProfileEditPlace) return new ProfileEditActivity((ProfileEditPlace)place,requests,placeController);
		if (place instanceof CreateJobPlace) return new CreateJobActivity((CreateJobPlace)place, requests, placeController);
		if (place instanceof ProviderJobsPlace) return new ProviderJobsActivity((MenuItemPlace)place, requests, placeController);
		if (place instanceof FindJobPlace) return new PerformerJobsActivity((FindJobPlace)place, requests, placeController);
		if (place instanceof PerformerJobsPlace) return new PerformerJobsActivity((PerformerJobsPlace)place, requests, placeController);
		if (place instanceof PerformerMainPlace) return new PerformerMainActivity((PerformerMainPlace)place, requests, placeController);
		if (place instanceof ProviderMainPlace) return new ProviderMainActivity((ProviderMainPlace)place, requests, placeController);
		if (place instanceof EditJobPlace) return new EditJobActivity((EditJobPlace)place, requests, placeController);
		return null;
	}

}
